#
# Generates the NodeHandler function that maps directives to directive nodes...
#

fout = open( "NodeHandler.py", "w")
fin = open( "directives/directives.txt", "r")

fout.write(
"""# NodeHandler.py
#
# This function maps directives to Directive Nodes
#

from directives import *

def MapDirective(directive, args):
""")

for l in fin:
    l = l[0:len(l)-1]
    fout.write("\tif directive.lower() == \"" + l + "\".lower():\n" )
    fout.write("\t\treturn " + l + "." + l + "(args)\n" )

fout.write("\tc = ConfigNode.ConfigNode()\n")
fout.write("\tc.directive = directive\n")
fout.write("\tc.args = args\n")
fout.write("\treturn c")

fout.close()
fin.close()
